<?php

/**
 * WaterFeeMsgtpl水费缴费执行模版
 * @author hjc19850430@gmail.com
 */
class WaterFeeMsgtpl extends BaseMsgtpl
{

	/**
	 * 给用户发消息
	 * @param array $orderInfo	订单信息
	 */
	public function sendMessageToUser($orderInfo,$accountId)
	{
		$wechatUserInfo = D('Wechat/WechatUser')->getInfo(array('user_id' => $orderInfo['user_id']),array('openid,subscribe'));
		$url = C('site_url').'/base/waterFee/logDetail/water_fee_id/'.$orderInfo['water_fee_id'].'/order_id/'.$orderInfo['order_id'];
		if($wechatUserInfo['subscribe']) {
			if($accountId == 2) {
				$this->wxTplSign = '-wKq2Sg22MBCCCsT_uVwOSOfMm1l0aRtml1vMlWLB88';
			} elseif($accountId == 5) {
				$this->wxTplSign = 'ATOvt4E9ucFQACkpS8_l7GTlZVGlVt-PiaEZD7u0-Po';
			}
			$userInfo = D('User')->getByPk($orderInfo['user_id']);
			$info = array(
				'first' => array("value" => '你已成功缴纳' . $orderInfo['order_amount'] . '元水费'),
				'keyword1' => array("value" => $userInfo['real_name']),
				'keyword2' => array("value" => $orderInfo['order_amount']),
				'keyword3' => array("value" => date('Y-m-d H:i')),
				'remark' => array("value" => '详情请登录系统查看'),
			);

			$this->wxObj->messageTpl($this->wechatInfo['appid'], $this->wechatInfo['appsecret'], $wechatUserInfo['openid'], $this->wxTplSign, $info, $url);
		}
	}
}
